
/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-08-08     甘泽       the first version
 */

#ifndef SENSOR_INA226_H_
#define SENSOR_INA226_H_

#define INA226_ADDR 0x80 // A0=GND，A1=GND // R=1, W=0

#define INA226_ID 0x2260

#define INA226_CONFIG 0x00
#define INA226_SHUNT_VOLTAGE 0x01
#define INA226_BUS_VOLTAGE 0x02
#define INA226_POWER 0x03
#define INA226_CURRENT 0x04
#define INA226_CALIB 0x05
#define INA226_MASK 0x06
#define INA226_ALERT 0x07
#define INA226_MANUFACTURE 0xFE // 0x5449
#define INA226_READ_ID 0xFF     // 0x2260

#define SHUNT_RESISTOR_OM 0.003f // 3毫欧
#define MAX_EXPECT_CURRENT 2.0f  // 最大通过电流 2A

struct ina226_sensor_info
{
    float bus_voltage;   /* mV */
    float shunt_voltage; /* mV */
    float current;       /* mA */
    float power;         /* mW */
};

int rt_ina226_sensor_register(void);

#endif